home *** CD-ROM | disk | FTP | other *** search
- ; ~
- ; Statement which plots a Sierpinski triangle in a Workbench window.
-
- ; Left mouse button quits.
-
- ; Adapted from Conrad Bessant's "Computers and Chaos" book,
- ; AmigaBASIC listing by Conrad Bessant.
-
- ; James L Boyd - jamesboyd@all-hail.freeserve.co.uk
-
- ; totally useless, but cool :)
-
- WbToScreen 0 ; gimme the wb screen
-
- NoCli
-
- *scr.Screen=Peek.l(Addr Screen(0)) ; get screen pointer
-
- ScreenToFront_ *scr ; show it
-
- Window 0,0,*scr\BarHeight+1,*scr\Width,*scr\Height-(*scr\BarHeight+1),$1800,"",1,2
-
- NPrint ""
- NPrint " Sierpi"+Chr$(241)+"ski Triangle"
-
- *rp.RastPort=RastPort (0)
-
- Statement PlotTri {x1.w,x2.w,x3.w,y1.w,y2.w,y3.w}
-
- ; PlotTri { centre, left, right, top, left bottom, right bottom }
-
- SHARED *rp.RastPort ; use the rastport we got earlier
-
- Dim x.w(2),y.w(2)
-
- x(0)=x1
- y(0)=y1
- x(1)=x2
- y(1)=y2
- x(2)=x3
- y(2)=y3
-
- vertex=Int(Rnd(3))
- px=x(vertex)
- py=y(vertex)
-
- While Joyb(0)=0
-
- vertex=Int(Rnd(3))
- px=px+(x(vertex)-px)/2
- py=py+(y(vertex)-py)/2
-
- SetAPen_ *rp,Int(Rnd(2^WBDepth)) ; choose random WB pen
-
- Move_ *rp,px,py ; remove for scary effect :)
- Draw_ *rp,px,py
-
- Wend
-
- End Statement
-
- ; let's go for full-window :)
-
- PlotTri {*scr\Width/2,0,*scr\Width,0,*scr\Height-(*scr\BarHeight+1),*scr\Height-(*scr\BarHeight+1)}
-
- End
-